package com.fanfan.controller;

import com.fanfan.pojo.Order;
import com.fanfan.pojo.domain.ResponseResult;
import com.fanfan.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;
    @GetMapping
    public ResponseResult listOrder(Integer pageNum, Integer pageSize, Order order){
        return orderService.listOrder(pageNum,pageSize,order);
    }
    @PutMapping("/{id}")
    public ResponseResult changeStatus(@PathVariable Long id){
        Order order = orderService.getById(id).setStatus("2");
        orderService.updateById(order);
        return ResponseResult.okResult();
    }
    @PutMapping("/changeStatus/{id}")
    public ResponseResult changeStatusIt(@PathVariable Long id){
        Order order = orderService.getById(id).setStatus("1");
        orderService.updateById(order);
        return ResponseResult.okResult();
    }
}
